package com.learning.jquizenglish.screen.learningfeed;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.learning.jquizenglish.R;
import com.learning.jquizenglish.common.adapter.BaseListAdapter;
import com.learning.jquizenglish.model.CommentModel;
import com.learning.jquizenglish.widget.ViewHolder;

public class CommentAdapter extends BaseListAdapter<CommentModel> {

	public CommentAdapter(Activity activity, ArrayList<CommentModel> datas) {
		super(activity, datas);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = LayoutInflater.from(mActivity).inflate(R.layout.comment_item, parent,false);
		}
		
		TextView txtName = ViewHolder.get(convertView, R.id.txtUser);
		TextView txtComment = ViewHolder.get(convertView, R.id.txtComment);
		CommentModel model = getItem(position);
		if (model!=null) {
			txtName.setText(model.user+": ");
			txtComment.setText(model.content);
		}
		return convertView;
	}

}
